home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / comm / misc / MakeFTPScript.lha / MakeFTPScript / ARexx / MakeFTPScript.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1999-03-19  |  1.8 KB  |  78 lines

  1. /* MakeFTPScript v1.7 by Grzegorz Fitrzyk SP9WUN (domagal@uci.agh.edu.pl)
  2.    
  3.    usage:    rx rexx:MakeFTPScript.rexx ADDRESS/K SOURCE/K DEST/K README/S
  4.    ex.:      rx rexx:MakeFTPScript.rexx ftp.wustl.edu ram:recent ram:script readme
  5.  
  6. */
  7.  
  8. parse arg ADDRESS source destin readflag
  9. parse var readflag ' ' readfl
  10.  
  11. MODE=''
  12. total=0
  13. header='#MKFTP1'
  14.  
  15. readfl=upper(readfl)
  16. destindx=destin||'.idx'
  17. options results
  18.  
  19. if Open(loadit, source, 'Read') then do    /* Open source file.*/
  20.   if Open(Saveit, destin, 'Write') then do /* Open destination file. */
  21.     call writeln(Saveit,header)
  22.     do forever
  23.       line=Readln(loadit)
  24.       if eof(loadit)~=0 then leave
  25.       if line="" then line="|"
  26.         parse var line '|'. header
  27.         if header="" then do
  28.           if line~="|" then do
  29.             call makeline
  30.           end
  31.       end
  32.     end
  33.   end; else call error_write
  34. end; else call error_read
  35.  
  36. say 'Total size of requested files 'total'KB'
  37. say 'Conversion succesfull.'
  38.  
  39. quitit:
  40. call close(saveit)
  41. call close(loadit)
  42. address command 'c:filenote 'destin' 'total'KB'
  43. exit
  44.  
  45. error_read:
  46. say 'Cant find source file: 'source
  47. call quitit
  48.  
  49. error_write:
  50. say 'Cant write destination file 'dest
  51. call quitit
  52.  
  53. makeline:
  54. parse var line filename direct size rest
  55. tt2=pos('+',size)
  56. size2=size
  57. if tt2~=0 then parse var size2 size '+'
  58. exten=right(size,1)
  59. if exten='?' then size='0K'
  60. temp=length(size)
  61. size=left(size,temp-1)
  62. size=translate(size,,' ')
  63. if exten="M" then size=size*1024
  64. total=total+size
  65. linecom='ncftp'||MODE||' '||ADDRESS||':'||'pub/aminet/'||direct||'/'||filename||'    #'||size
  66. call writeln(saveit,linecom)
  67. if readfl="README" then call doreadme
  68. return
  69.  
  70. doreadme:
  71. dlug=length(filename)
  72. readname=left(filename,dlug-3)
  73. linecom='ncftp'||MODE||' '||ADDRESS||':'||'pub/aminet/'||direct||'/'||readname||'readme'||'    #0'
  74. call writeln(saveit,linecom)
  75. size=0
  76. filename=readname||'readme'
  77. return
  78.